const Base = require('./base.js');
module.exports = class extends Base {

	async selectAll() {
		//		let value = await think.cache("setup", () => {
		//			return this.lists();
		//		}, {
		//			timeout: 365 * 24 * 3600
		//		});

		let value = await this.lists();

		return value;
	}
	async lists() {

		const list = await this.order('sort ASC').field(['code', 'value', 'type']).select();
		const obj = {};
		list.forEach(v => {
			if(Number(v.type) == 1) {
				v.value = v.value.replace(/\r/g,'').split('\n');
				const obj = {};
				v.value.forEach(n => {
					n = n.split(':');
					obj[n[0]] = n[1];
				});
				v.value = obj;
			}
			obj[v.code] = v.value;
		});
		return obj;
	}
	
	
};